<div [@routerTransition]>
    <div class="content d-flex flex-column flex-column-fluid">
        <sub-header [title]="'Editions' | localize" [description]="'EditionsHeaderInfo' | localize">
            <div role="actions">
                <button *ngIf="'Pages.Editions.Create' | permission" class="btn btn-primary"
                        (click)="createEdition()"><i class="fa fa-plus"></i>
                    {{"CreateNewEdition" | localize}}</button>
            </div>
        </sub-header>

        <div [class]="containerClass">
            <div class="card card-custom gutter-b">
                <div class="card-body">
                    <div class="row align-items-center">
                        <!--<Primeng-TurboTable-Start>-->
                        <div class="col primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                            <p-table #dataTable (onLazyLoad)="getEditions()" [value]="primengTableHelper.records"
                                     rows="{{primengTableHelper.defaultRecordsCountPerPage}}" [paginator]="false"
                                     [lazy]="true" [responsive]="primengTableHelper.isResponsive">
                                <ng-template pTemplate="header">
                                    <tr>
                                        <th style="width: 130px;"
                                            [hidden]="!(['Pages.Editions.Edit', 'Pages.Editions.Delete'] | permissionAny)">
                                            {{'Actions' | localize}}
                                        </th>
                                        <th>
                                            {{'EditionName' | localize}}
                                        </th>
                                        <th>
                                            {{'Price' | localize}}
                                        </th>
                                        <th>
                                            {{'IsTrialActive' | localize}}
                                        </th>
                                        <th>
                                            {{'WaitingDayAfterExpire' | localize}}
                                        </th>
                                        <th>
                                            {{'ExpiringEdition' | localize}}
                                        </th>
                                    </tr>
                                </ng-template>
                                <ng-template pTemplate="body" let-record="$implicit">
                                    <tr>
                                        <td style="width: 130px;text-align:center">
                                            <div class="btn-group dropdown" dropdown>
                                                <button dropdownToggle class="dropdown-toggle btn btn-sm btn-primary">
                                                    <i class="fa fa-cog"></i><span class="caret"></span>
                                                    {{"Actions" | localize}}
                                                </button>
                                                <ul class="dropdown-menu" *dropdownMenu>
                                                    <li>
                                                        <a href="javascript:;" class="dropdown-item"
                                                           *ngIf="'Pages.Editions.Edit' | permission"
                                                           (click)="editEditionModal.show(record.id)">{{'Edit' | localize}}</a>
                                                    </li>

                                                    <li>
                                                        <a href="javascript:;" class="dropdown-item"
                                                           *ngIf="'Pages.Editions.Delete' | permission"
                                                           (click)="deleteEdition(record)">{{'Delete' | localize}}</a>
                                                    </li>

                                                    <li>
                                                        <a href="javascript:;" class="dropdown-item"
                                                           *ngIf="'Pages.Editions.MoveTenantsToAnotherEdition' | permission"
                                                           (click)="moveTenantsToAnotherEditionModal.show(record.id)">{{'MoveTenantsToAnotherEdition' | localize}}</a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </td>
                                        <td>
                                            <span class="ui-column-title">{{'EditionName' | localize}}</span>
                                            {{record.displayName}}
                                        </td>
                                        <td>
                                            <span class="ui-column-title">{{'Price' | localize}}</span>
                                            <span
                                                *ngIf="record.dailyPrice || record.weeklyPrice || record.monthlyPrice || record.annualPrice">
                                            {{appSession.application.currencySign}}{{record.dailyPrice}} {{"Daily" | localize }}
                                                /
                                                {{appSession.application.currencySign}}{{record.weeklyPrice}} {{"Weekly" | localize }}
                                                /
                                                {{appSession.application.currencySign}}{{record.monthlyPrice}} {{"Monthly" | localize }}
                                                /
                                                {{appSession.application.currencySign}}{{record.annualPrice}} {{"Annual" | localize }}
                                        </span>
                                            <span
                                                *ngIf="!record.dailyPrice && !record.weeklyPrice && !record.monthlyPrice && !record.annualPrice">
                                            {{"Free" | localize}}
                                        </span>
                                        </td>
                                        <td>
                                            <span class="ui-column-title">{{'IsTrialActive' | localize}}</span>
                                            <span *ngIf="record.trialDayCount">
                                                {{"Yes" | localize}}, {{record.trialDayCount}} {{"Days" | localize}}
                                            </span>
                                            <span *ngIf="!record.trialDayCount">
                                                {{"No" | localize}}
                                            </span>
                                        </td>
                                        <td>
                                            <span class="ui-column-title">{{'WaitingDayAfterExpire' | localize}}</span>
                                            {{record.waitingDayAfterExpire}}
                                        </td>
                                        <td>
                                            <span class="ui-column-title">{{'ExpiringEdition' | localize}}</span>
                                            {{record.expiringEditionDisplayName}}
                                        </td>
                                    </tr>
                                </ng-template>
                            </p-table>
                            <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
                                {{'NoData' | localize}}
                            </div>
                            <div class="ui-table-footer">
                            </div>
                        </div>
                        <!--<Primeng-TurboTable-End>-->
                    </div>
                </div>
            </div>
        </div>
    </div>

    <createEditionModal #createEditionModal (modalSave)="getEditions()"></createEditionModal>
    <editEditionModal #editEditionModal (modalSave)="getEditions()"></editEditionModal>
    <moveTenantsToAnotherEditionModal #moveTenantsToAnotherEditionModal></moveTenantsToAnotherEditionModal>
</div>
